package com.net.protocol.message.body.receiver;

import com.net.protocol.message.Message;
import com.net.protocol.util.BitUtils;

import java.io.UnsupportedEncodingException;

public class Common_ACK implements Message.Body.Receiver.ACK{
    private int msgId; //应答ID(对应的终端消息的ID)
    private int seqId; //应答流水号(对应的终端消息的流水号)
    public byte result; //返回结果(0:成功/确认;1:失败)

    public int getSeqId() {
        return seqId;
    }

    public int getMsgId() {
        return msgId;
    }

    public byte getResult() {
        return result;
    }

    @Override
    public String toString() {
        return "CommonACK{" + "seqId=" + seqId + ", msgId=" + msgId + ", result=" + result + '}';
    }

    @Override
    public void unpack(byte[] buf, int offset, int length) throws UnsupportedEncodingException {
        msgId = BitUtils.readInt16(buf,offset);
        seqId = BitUtils.readInt16(buf,offset+2);
        result = buf[offset+4];
    }
}
